package PAT;

import java.util.Scanner;

public class PAT1152 {
    public static boolean isPrime(int p){
        if(p==2 || p==3) return true;
        if(p%6!=1 && p%6!=5) return false;
        for (int i = 5; i * i <= p; i+=6) {
            if(p%i==0||p%(i+2)==0){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        String str = scanner.next();
        boolean flag = false;
        for (int i = 0; i + m -1 < n; i++) {
            String substring = str.substring(i, i + m);
            if(isPrime(Integer.parseInt(substring))){
                System.out.println(substring);
                flag = true;
                break;
            }
        }
        if(!flag){
            System.out.println("404");
        }
    }
}
